<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>活动管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			if($("#text1").val() == ''){
				$("#text1").val('<p align="justify" class="MsoNormal" style="mso-pagination:none;text-align:justify;text-justify:inter-ideograph;\n' +
						'mso-list:l0 level1 lfo1;">\n' +
						'\t<span style="font-size: 10.5pt;"><font style="">1.</font><font face="宋体" style="font-family: 宋体;">本活动在报名有效期内可进行报名，报名结束后，报名人数达到最低报名人数（</font><font face="Calibri" style="font-family: 宋体;">10</font><font face="宋体" style="font-family: 宋体;">人）要求，方可报名成功，否则报名失败；</font></span><span style="mso-spacerun:\'yes\';font-family:宋体;mso-ascii-font-family:Calibri;\n' +
						'mso-hansi-font-family:Calibri;mso-bidi-font-family:\'Times New Roman\';font-size:10.5000pt;' +
						'mso-font-kerning:1.0000pt;">' +
						'<p align="justify" class="MsoNormal" style="mso-pagination:none;text-align:justify;text-justify:inter-ideograph;\n' +
						'mso-list:l0 level1 lfo1;">\n' +
						'\t2.<span style="mso-spacerun:\'yes\';font-family:宋体;mso-ascii-font-family:Calibri;\n' +
						'mso-hansi-font-family:Calibri;mso-bidi-font-family:\'Times New Roman\';font-size:10.5000pt;\n' +
						'mso-font-kerning:1.0000pt;">报名后，在报名有效期内都可进行取消预约操作，报名结束后不可进行取消预约操作；</span><span style="mso-spacerun:\'yes\';font-family:Calibri;mso-fareast-font-family:宋体;\n' +
						'mso-bidi-font-family:\'Times New Roman\';font-size:10.5000pt;mso-font-kerning:1.0000pt;"><p></p></span></p>')
			}
			$("#inputForm").validate({
				submitHandler: function(form){
					// var type = $('input[name="actionDetailType"]:checked').val()
					var type = 2;
					if(type == 1){
						$("#actionDetailDate").val($("#actionDetailDateTemp").val())
					}
					if(type == 2){
						var a = ""
						if($("#detailOneBegin").val() != ""){
							a  = a +  $("#detailOneBegin").val() + "-" + $("#detailOneEnd").val() + ","
							$("#amStartDate").val($("#detailOneBegin").val())
							$("#amEndDate").val($("#detailOneEnd").val())
						}
						if($("#detailTwoBegin").val() != ""){
							a  = a +  $("#detailTwoBegin").val() + "-" + $("#detailTwoEnd").val() + ","
							$("#pmStartDate").val($("#detailTwoBegin").val())
							$("#pmEndDate").val($("#detailTwoEnd").val())
						}
						if($("#detailThreeBegin").val() != ""){
							a  = a +  $("#detailThreeBegin").val() + "-" + $("#detailThreeEnd").val() + ","
						}
						if(a == ""){
							alert("请添加时间段！")
							return;
						}
						a = a.substr(0, a.length - 1);
						$("#actionDetailDate").val(a);
					}
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			$("#fee").keydown(function (e) {
				e.target.value = (e.target.value.match(/^\d*(\.?\d{0,1})/g)[0]) || null

			})
			$("input[name='actionDetailType']").click(function() {
				if($(this).val() == 1){
					$("#typeOne").show()
					$("#typeTwo").hide()
					$("#detailOneDiv").hide()
					$("#detailTwoDiv").hide()
					$("#detailThreeDiv").hide()
					$("#detailOneBegin").val("")
					$("#detailOneEnd").val("")
					$("#detailTwoBegin").val("")
					$("#detailTwoEnd").val("")
					$("#detailThreeBegin").val("")
					$("#detailThreeEnd").val("")
				}else{
					$("#typeOne").hide()
					$("#typeTwo").show()
				}
			})


		});
		function addBtn2() {
			if ($("#detailOneDiv").css("display") == "none") {
				$("#detailOneDiv").show();
				return;
			}
			if ($("#detailTwoDiv").css("display") == "none") {
				$("#detailTwoDiv").show();
				return;
			}
			// if ($("#detailThreeDiv").css("display") == "none") {
			// 	$("#detailThreeDiv").show();
			// 	return;
			// }
			alert("最多设置2个时间段！")
		}
		function deleteBtn(a) {
			if (a == 1) {
				$("#detailOneBegin").val("")
				$("#detailOneEnd").val("")
				$("#amStock").val(0)
				$("#detailOneDiv").hide()
			}
			if (a == 2) {
				$("#detailTwoBegin").val("")
				$("#detailTwoEnd").val("")
				$("#pmStock").val(0)
				$("#detailTwoDiv").hide()
			}
			if (a == 3) {
				$("#detailThreeBegin").val("")
				$("#detailThreeEnd").val("")
				$("#detailThreeDiv").hide()
			}
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/phy/tAction/">活动列表</a></li>
		<li class="active"><a href="${ctx}/phy/tAction/form?id=${tAction.id}">活动<shiro:hasPermission name="phy:tAction:edit">${not empty tAction.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="phy:tAction:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="tAction" action="${ctx}/phy/tAction/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>
		<c:if test="${empty admin.tenantId}" >
			<div class="control-group" >
				<label class="control-label">所属机构:</label>
				<div class="controls">
					<sys:treeselect id="tenant" name="tenantId" value="${tAction.tenantId}" labelName="tenantName" labelValue="${tAction.tenant.tenantName}"
									title="租户" url="/tenant/tTenant/treeData" cssClass="required" notAllowSelectParent="true"/>
					<span class="help-inline"><font color="red">*</font> </span>
				</div>
			</div>
		</c:if>
		<c:if test="${not empty admin.tenantId}">
			<form:hidden path="tenantId" value="${admin.tenantId}"></form:hidden>
		</c:if>
		<div class="control-group">
			<label class="control-label">医生选择:</label>
			<div class="controls">
				<sys:treeselect id="doctor" name="doctorId" value="${tAction.doctorId}" labelName="doctorName" labelValue="${tAction.doctor.doctorName}"
								title="医生" url="/phy/tDoctor/treeData" cssClass="required" notAllowSelectParent="true"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">坐诊时间：</label>
			<div class="controls">
				<input name="actionDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate required"
					value="<fmt:formatDate value="${tAction.actionDate}" pattern="yyyy-MM-dd"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">排序(越大越靠前)：</label>
			<div class="controls">
				<form:input path="sort" htmlEscape="false" maxlength="3" class="input-mini number" value="100"/>
			</div>
		</div>
<%--		<div class="control-group">--%>
<%--			<label class="control-label">排班类型：</label>--%>
<%--			<div class="controls">--%>
<%--				<form:radiobuttons element="label <span style = \"margin-right:20px;\"></span" path="actionDetailType" items="${fns:getDictList('action_detail_type')}" itemLabel="label" itemValue="value" htmlEscape="false" class="required"/>--%>
<%--				<span class="help-inline"><font color="red">*</font> </span>--%>
<%--			</div>--%>
<%--		</div>--%>
<%--		<c:if test="${tAction.actionDetailType == 1}">--%>
<%--			<div class="control-group" id="typeOne">--%>
<%--		</c:if>--%>
<%--		<c:if test="${tAction.actionDetailType != 1}">--%>
<%--			<div class="control-group" id="typeOne" style="display: none">--%>
<%--		</c:if>--%>
<%--			<label class="control-label">坐诊时间段：</label>--%>
<%--			<div class="controls">--%>
<%--				<input value="${detailDate}" id="actionDetailDateTemp" htmlEscape="false" readonly maxlength="255" class="input-xlarge detail required"/>--%>
<%--				<span class="help-inline"><font color="red">*</font> </span>--%>
<%--			</div>--%>
<%--		</div>--%>
<%--		<c:if test="${tAction.actionDetailType == 2}">--%>
			<div class="control-group" id="typeTwo">
<%--		</c:if>--%>
<%--		<c:if test="${tAction.actionDetailType != 2}">--%>
<%--			<div class="control-group" id="typeTwo" style="display: none">--%>
<%--		</c:if>--%>
			<label class="control-label">坐诊时间段：</label>
			<div class="controls">
				<form:hidden path="actionDetailDate" htmlEscape="false" maxlength="255" class="input-xlarge detail required"/>
				<input type="hidden" id="amStartDate" name="amStartDate" htmlEscape="false" maxlength="255" class="input-xlarge detail required"/>
				<input type="hidden" id="amEndDate" name="amEndDate" htmlEscape="false" maxlength="255" class="input-xlarge detail required"/>
				<input type="hidden" id="pmStartDate" name="pmStartDate" htmlEscape="false" maxlength="255" class="input-xlarge detail required"/>
				<input type="hidden" id="pmEndDate" name="pmEndDate" htmlEscape="false" maxlength="255" class="input-xlarge detail required"/>
				<input id="addBtn" class="btn btn-primary" type="button" onclick="addBtn2()" value="添 加"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
			</div>
<%--		<c:if test="${empty tAction.dateOneBgein}">--%>
<%--		<div class="control-group" id="detailOneDiv" style="display: none">--%>
<%--			</c:if>--%>
<%--		<c:if test="${not empty tAction.dateOneBgein}">--%>
		<div class="control-group" id="detailOneDiv" >
<%--			</c:if>--%>
			<label class="control-label">上午：</label>
			<div class="controls">
				<input id="detailOneBegin" type="text" readonly="readonly"  class="input-medium Wdate required"
					   value="${tAction.amStartDate}"
					   onclick="WdatePicker({dateFmt:'HH:mm',isShowClear:false});"/>
				<span class="help-inline">--</span>
				<input id="detailOneEnd" type="text" readonly="readonly"  class="input-medium Wdate required"
					   value="${tAction.amEndDate}"
					   onclick="WdatePicker({dateFmt:'HH:mm',isShowClear:false});"/>
				<span> 号源数：</span>
				<form:input path="amStock" htmlEscape="false" maxlength="3" class="input-mini number required" />
				<input class="btn" type="button" onclick="deleteBtn(1)" value="删 除"/>
			</div>
		</div>
		<c:if test="${empty tAction.pmStartDate}">
		<div class="control-group" id="detailTwoDiv" style="display: none">
			</c:if>
		<c:if test="${not empty tAction.pmStartDate}">
		<div class="control-group" id="detailTwoDiv" >
			</c:if>
			<label class="control-label">下午：</label>
			<input style="margin-left: 20px" id="detailTwoBegin" type="text" readonly="readonly"  class="input-medium Wdate required"
					value="${tAction.pmStartDate}"
					onclick="WdatePicker({dateFmt:'HH:mm',isShowClear:false});"/>
			<span class="help-inline">--</span>
			<input id="detailTwoEnd" type="text" readonly="readonly"  class="input-medium Wdate required"
				   value="${tAction.pmEndDate}"
				   onclick="WdatePicker({dateFmt:'HH:mm',isShowClear:false});"/>
			<span> 号源数：</span>
			<form:input path="pmStock" htmlEscape="false" maxlength="3" class="input-mini number required" />
			<input class="btn" type="button" onclick="deleteBtn(2)" value="删 除"/>
		</div>
		<c:if test="${empty tAction.dateThreeBgein}">
		<div class="control-group" id="detailThreeDiv" style="display: none">
			</c:if>
		<c:if test="${not empty tAction.dateThreeBgein}">
		<div class="control-group" id="detailThreeDiv" >
			</c:if>
			<label class="control-label">时间段3：</label>
			<input style="margin-left: 20px" id="detailThreeBegin" type="text" readonly="readonly"  class="input-medium Wdate required"
				   value="${tAction.dateThreeBgein}"
				   onclick="WdatePicker({dateFmt:'HH:mm:ss',isShowClear:false});"/>
			<span class="help-inline">--</span>
			<input id="detailThreeEnd" type="text" readonly="readonly"  class="input-medium Wdate required"
				   value="${tAction.dateThreeEnd}"
				   onclick="WdatePicker({dateFmt:'HH:mm:ss',isShowClear:false});"/>
			<input class="btn" type="button" onclick="deleteBtn(3)" value="删 除"/>
		</div>
		<div class="control-group">
			<label class="control-label">活动规则：</label>
			<div class="controls">
				<form:textarea path="rule" htmlEscape="false" rows="4" class="input-xxlarge " id="text1"/>
				<sys:ckeditor replace="rule" uploadPath="/cms/article" height="300px" />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">活动开始时间：</label>
			<div class="controls">
				<input name="beginDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate required"
					value="<fmt:formatDate value="${tAction.beginDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">活动结束时间：</label>
			<div class="controls">
				<input name="endDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate required"
					value="<fmt:formatDate value="${tAction.endDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">报名费用：</label>
			<div class="controls">
				<form:input path="fee" htmlEscape="false" class="input-mini required"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">最低报名人数：</label>
			<div class="controls">
				<form:input path="minPeople" htmlEscape="false" maxlength="11" class="input-mini required digits"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">备注信息：</label>
			<div class="controls">
				<form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="255" class="input-xxlarge "/>
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="phy:tAction:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
<script type="text/javascript">
	$(document).ready(function() {
		alert("11")
		if($("#text1").val() == ''){
			alert("22")
			$("#text1").val('222')
		}
	})
</script>
</html>
